package com.recruit.admin.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.validator.Form;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class ChangePasswordForm extends Form {
	private String oldPassword;
	private String newPassword;
	public String getOldPassword() {
		return oldPassword;
	}
	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}
	public String getNewPassword() {
		return newPassword;
	}
	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request){
		ActionErrors errors = new ActionErrors();
		if(this.oldPassword.equals("")){
			errors.add("oldPassword", new ActionMessage("changePW.no.password.error"));
		}
		if(this.newPassword.equals(this.oldPassword)){
			errors.add("newPassword", new ActionMessage("changePW.no.repassword.error"));
		}
		return errors;
	}
}
